//
//  StatusButton.m
//  LiveEducation
//
//  Created by Liu,Qingcan on 2017/4/11.
//  Copyright © 2017年 Baidu. All rights reserved.
//

#import "StatusButton.h"
@interface StatusButton()

@property (nonatomic,strong)UIImageView *statusImageView;
@property (nonatomic,strong)UILabel *statusLabel;

@end

@implementation StatusButton

- (instancetype)initButtonWithImageName:(NSString *)statusImageName subTitle:(NSString *)title frame:(CGRect)frame{
//    self = [UIButton buttonWithType:UIButtonTypeCustom];
    self = [super init];
    if (self) {
        self.frame = frame;
        self.statusImageView.image = [UIImage imageNamed:statusImageName];
        self.statusLabel.text = title;
        
        [self addSubview:self.statusImageView];
        [self addSubview:self.statusLabel];
        //    [self bringSubviewToFront:self.statusImageView];
    }
    
    return self;
}

+ (instancetype)initButtonWithImageName:(NSString *)statusImageName subTitle:(NSString *)title frame:(CGRect)frame{
//    StatusButton * button = [[self alloc]init];
    return [[self alloc] initButtonWithImageName:statusImageName subTitle:title frame:frame];
}


//- (void)layoutSubviews{
//    [super layoutSubviews];
//}

- (UIImageView *)statusImageView{
    if (!_statusImageView) {
        _statusImageView = [[UIImageView alloc]init];
        _statusImageView.frame = CGRectMake(self.bounds.size.width/2-15, 6, 30, self.bounds.size.height - 50);
        _statusImageView.contentMode = UIViewContentModeScaleToFill;
//        _statusImageView.layer.cornerRadius = 
    }
    return _statusImageView;
}

- (UILabel *)statusLabel{
    if (!_statusLabel) {
        _statusLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.bounds.size.width/2-25, self.statusImageView.bounds.size.height + 8, 50, 28)];
        _statusLabel.numberOfLines = 1;
        _statusLabel.font = [UIFont systemFontOfSize:11];
        _statusLabel.textAlignment = NSTextAlignmentCenter;
//        _statusLabel.backgroundColor = [UIColor purpleColor];
    }
    return _statusLabel;
}

@end
